﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

using TribesPSO;

namespace TribesPSOTest.NUnit
{
	public class Particle_Accessor
	{
		private Particle particle;

		public Particle_Accessor(Particle particle)
		{
			this.particle = particle;
		}

		public void MemorizePerformance(bool improvedBestPerformance)
		{
			typeof(Particle)
				.InvokeMember(
					"MemorizePerformance"
					, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod
					, null
					, particle
					, new object[] { improvedBestPerformance });
		}

		public EuclidianVector CalculateNewPosition(Solution bestInformerSolution)
		{
			return particle
				.GetType()
				.InvokeMember(
					"CalculateNewPosition"
					, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod
					, null
					, particle
					, new object[] { bestInformerSolution })
				as EuclidianVector;
		}

		public bool IsGood
		{
			get
			{
				return particle.IsGood;
			}
		}

		public bool IsExcellent
		{
			get
			{
				return particle.IsExcellent;
			}
		}
	}
}
